﻿//    Copyright 2010,2011 Himanshu Vasishth
//   
//    This file is part of SecretVault.
//
//    SecretVault is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    SecretVault is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with SecretVault.  If not, see <http://www.gnu.org/licenses/>.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PasswordStoreProvider;
using PasswordLocker.Controls;

namespace PasswordLocker.UI
{
    public partial class SecretVaultForm : Form
    {
        public SecretVaultForm()
        {
            InitializeComponent();
            appNameLabel.Font = Fonts.HeaderFont;
            appNameLabel.Text = Resources.AppName;
        }

        public IEnumerable<LoginInfo> LoginInfos
        {
            set { loginInfoListControl1.LoginInfos = value; }
        }

        public void ShowPassword(LoginInfo loginInfo, string password)
        {
            loginInfoListControl1.ShowPassword(loginInfo, password);
        }

        public string StoreLocation
        {
            get { return storePathTextBox.Text; }
            set { storePathTextBox.Text = value; }
        }

        public event LoginInfoEvent ShowPasswordClicked
        {
            add { loginInfoListControl1.ShowPasswordClicked += value; }
            remove { loginInfoListControl1.ShowPasswordClicked -= value; }
        }

        public event LoginInfoEvent DeleteLoginInfoClicked
        {
            add { loginInfoListControl1.DeleteClicked += value; }
            remove { loginInfoListControl1.DeleteClicked -= value; }
        }

        public event LoginInfoEvent ChangeLoginInfoClicked
        {
            add { loginInfoListControl1.ChangeClicked += value; }
            remove { loginInfoListControl1.ChangeClicked -= value; }
        }

        public event EventHandler AddClicked
        {
            add { loginInfoListControl1.AddClicked += value; }
            remove { loginInfoListControl1.AddClicked -= value; }
        }

        public event EventHandler ChangeMasterPassword;

        private void ChangeMasterPasswordClicked(object sender, EventArgs e)
        {
            if(ChangeMasterPassword != null)
            {
                ChangeMasterPassword(this, e);
            }
        }
    }
}
